import React, {Component} from 'react';
import {connect} from "react-redux";
// import mapDispatchToProps from "react-redux/lib/connect/mapDispatchToProps";
// import mapStateToProps from "react-redux/lib/connect/mapStateToProps";

class TodoList extends Component {


    render() {
        return (
            <div>
                <input type="text" value={this.props.inputVal} onChange={this.props.changeIptV}/>
                <button onClick={this.props.submit}>提交</button>
                <ul>
                    <li>latmy</li>
                </ul>
            </div>
        );
    }
}

const mapStateToProps = (state) => {
    return {
        inputVal: state.inputVal
    }
}
const mapDispatchToProps = (dispatch) => {
    return {
        changeIptV(e) {
            console.log(e.target.value)
            const action = {
                type: 'change_input_val',
                value: e.target.value
            }
            dispatch(action)
        },
        submit() {
            console.log('em in ')
            const action = {
                type: 'push_list'
            }
            dispatch(action)
        }
    }
}
export default connect(mapStateToProps, mapDispatchToProps)(TodoList);
